<?php
	session_start();
	include('db_connection.php');
	
	$id = $_GET['id'];
	$act_id = $_GET['uic'];
	$selct_query = "SELECT * FROM tbl_user WHERE id='".$id."' AND activate_link='".$act_id."' AND is_active='0'";
	$fetch_query = mysql_query($selct_query) or die(mysql_error());

	$count = '';
	while($data_array = mysql_fetch_array($fetch_query)){
		$id = $data_array['id'];
		$act_key = $data_array['activate_link'];					
		$is_active = $data_array['is_active'];
		$user_name = $data_array['username'];
		$user_email = $data_array['email'];
		$count = $data_array['count'];
	}				
	
	$row = mysql_num_rows($fetch_query);

	if($row){
		$count = $count+1;
		$update ="UPDATE tbl_user SET count = '".$count."', is_active='1', update_ts=now() WHERE id='".$id."' AND activate_link='".$act_id."'";
		$fetch_update = mysql_query($update) or die(mysql_error());
		header('Location: ../index.php?home=1');
	}else{
		$sel_query = "SELECT * FROM tbl_user WHERE id='".$id."' AND activate_link='".$act_id."'";		
		$fetch_sel = mysql_query($sel_query) or die(mysql_error());
		$row_sel = mysql_num_rows($fetch_sel);
		if($row_sel){			
			header('Location: ../index.php?home=1');
		}else{
			header('Location: ../index.php?home=1');
		}
	}
?>